package com.wufun.overseas.joystick.map;

import android.view.KeyEvent;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * Created by caowd on 2015/6/13.
 */
public class HandShankUtil {

    public static final Map<String, String> nameToName = new HashMap<String, String>();

    public static boolean isAllowSet(String key) {
        return !(key.equals(KEY_DPAD_LEFT) || key.equals(KEY_DPAD_RIGHT) || key.equals(KEY_DPAD_UP) || key.equals(KEY_DPAD_DOWN) || key.equals(KEY_BUTTON_THUMBL));

    }

    public static boolean isAllowSetWSC(String key) {
        return !key.equals(KEY_BUTTON_THUMBL);

    }

    static {
        nameToName.put("KEY_SELECT", "select");
        nameToName.put("KEY_START", "start");
        nameToName.put("KEY_X", "X");
        nameToName.put("KEY_Y", "Y");
        nameToName.put("KEY_A", "A");
        nameToName.put("KEY_B", "B");
        nameToName.put("KEY_L1", "L1");
        nameToName.put("KEY_L2", "L2");
        nameToName.put("KEY_R1", "R1");
        nameToName.put("KEY_R2", "R2");
        nameToName.put("KEY_BUTTON_THUMBL", "THUMBL");
        nameToName.put("KEY_BUTTON_THUMBR", "THUMBR");
        nameToName.put("KEY_DPAD_LEFT", "LEFT");
        nameToName.put("KEY_DPAD_UP", "UP");
        nameToName.put("KEY_DPAD_DOWN", "DOWN");
        nameToName.put("KEY_DPAD_RIGHT", "RIGHT");


    }

    public static Object valueGetKey(Map map, Object value) {
        Set set = map.entrySet();
        Iterator it = set.iterator();
        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry) it.next();
            if (entry.getValue().equals(value)) {
                Object s = entry.getKey();
                return s;
            }
        }
        return null;
    }


    public static final Map<String, Integer> map        = new HashMap<String, Integer>();
    public static final String               KEY_SELECT = "KEY_SELECT";
    public static final String               KEY_START  = "KEY_START";

    public static final String KEY_X = "KEY_X";
    public static final String KEY_Y = "KEY_Y";
    public static final String KEY_A = "KEY_A";
    public static final String KEY_B = "KEY_B";

    public static final String KEY_L1 = "KEY_L1";
    public static final String KEY_L2 = "KEY_L2";
    public static final String KEY_R1 = "KEY_R1";
    public static final String KEY_R2 = "KEY_R2";

    public static final String KEY_DPAD_LEFT  = "KEY_DPAD_LEFT";
    public static final String KEY_DPAD_UP    = "KEY_DPAD_UP";
    public static final String KEY_DPAD_DOWN  = "KEY_DPAD_DOWN";
    public static final String KEY_DPAD_RIGHT = "KEY_DPAD_RIGHT";

    public static final String KEY_BUTTON_THUMBL = "KEY_BUTTON_THUMBL";
    public static final String KEY_BUTTON_THUMBR = "KEY_BUTTON_THUMBR";


    static {
        map.put(KEY_SELECT, KeyEvent.KEYCODE_BUTTON_SELECT);
        map.put(KEY_START, KeyEvent.KEYCODE_BUTTON_START);
        map.put(KEY_X, KeyEvent.KEYCODE_BUTTON_X);
        map.put(KEY_Y, KeyEvent.KEYCODE_BUTTON_Y);
        map.put(KEY_A, KeyEvent.KEYCODE_BUTTON_A);
        map.put(KEY_B, KeyEvent.KEYCODE_BUTTON_B);
        map.put(KEY_L1, KeyEvent.KEYCODE_BUTTON_L1);
        map.put(KEY_L2, KeyEvent.KEYCODE_BUTTON_L2);
        map.put(KEY_R1, KeyEvent.KEYCODE_BUTTON_R1);
        map.put(KEY_R2, KeyEvent.KEYCODE_BUTTON_R2);
        map.put(KEY_DPAD_LEFT, KeyEvent.KEYCODE_DPAD_LEFT);
        map.put(KEY_DPAD_UP, KeyEvent.KEYCODE_DPAD_UP);
        map.put(KEY_DPAD_DOWN, KeyEvent.KEYCODE_DPAD_DOWN);
        map.put(KEY_DPAD_RIGHT, KeyEvent.KEYCODE_DPAD_RIGHT);
        map.put(KEY_BUTTON_THUMBL, KeyEvent.KEYCODE_BUTTON_THUMBL);
        map.put(KEY_BUTTON_THUMBR, KeyEvent.KEYCODE_BUTTON_THUMBR);
    }

    public static final Map<Integer, String> fcMap = new HashMap<Integer, String>();


    public static final String FC_KEY_SELECT = /*KeyMap.fcKeysKey[0];*/"FC_KEY_SELECT";
    public static final String FC_KEY_START  =/* KeyMap.fcKeysKey[1];*/"FC_KEY_START";
    public static final String FC_KEY_A      =/* KeyMap.fcKeysKey[2];*/"FC_KEY_A";
    public static final String FC_KEY_B      = /*KeyMap.fcKeysKey[3];*/"FC_KEY_B";

    public static final String FC_KEY_TURBO_A = /*KeyMap.fcKeysKey[4];*/"FC_KEY_TURBO_A";
    public static final String FC_KEY_TURBO_B = /*KeyMap.fcKeysKey[5];*/"FC_KEY_TURBO_B";
    public static final String FC_KEY_AB      = /*KeyMap.fcKeysKey[6];*/"FC_KEY_AB";

    public static final Map<String, String> fcConvertMap = new HashMap<String, String>();

    static {
        fcConvertMap.put(FC_KEY_SELECT, KeyMap.fcKeysKey[0]);
        fcConvertMap.put(FC_KEY_START, KeyMap.fcKeysKey[1]);
        fcConvertMap.put(FC_KEY_TURBO_B, KeyMap.fcKeysKey[2]);
        fcConvertMap.put(FC_KEY_TURBO_A, KeyMap.fcKeysKey[3]);
        fcConvertMap.put(FC_KEY_B, KeyMap.fcKeysKey[4]);
        fcConvertMap.put(FC_KEY_A, KeyMap.fcKeysKey[5]);
        fcConvertMap.put(FC_KEY_AB, KeyMap.fcKeysKey[6]);
    }

    {
        fcMap.put(KeyEvent.KEYCODE_BUTTON_SELECT, FC_KEY_SELECT);
        fcMap.put(KeyEvent.KEYCODE_BUTTON_START, FC_KEY_START);

        fcMap.put(KeyEvent.KEYCODE_BUTTON_A, FC_KEY_A);
        fcMap.put(KeyEvent.KEYCODE_BUTTON_B, FC_KEY_B);

        fcMap.put(KeyEvent.KEYCODE_BUTTON_X, FC_KEY_TURBO_A);
        fcMap.put(KeyEvent.KEYCODE_BUTTON_Y, FC_KEY_TURBO_B);

        fcMap.put(KeyEvent.KEYCODE_BUTTON_R1, FC_KEY_AB);

    }

    public static final Map<Integer, String> gbaMap = new HashMap<Integer, String>();


    public static final String GBA_KEY_SELECT = /*KeyMap.gbaKeysKey[0];*/"GBA_KEY_SELECT";
    public static final String GBA_KEY_START  =  /*KeyMap.gbaKeysKey[1];*/"GBA_KEY_START";
    public static final String GBA_KEY_A      = /* KeyMap.gbaKeysKey[2];*/"GBA_KEY_A";
    public static final String GBA_KEY_B      =  /*KeyMap.gbaKeysKey[3];*/"GBA_KEY_B";

    public static final String GBA_KEY_L       =  /*KeyMap.gbaKeysKey[4];*/"GBA_KEY_L";
    public static final String GBA_KEY_R       =  /*KeyMap.gbaKeysKey[5];*/"GBA_KEY_R";
    public static final String GBA_KEY_TURBO_A =  /*KeyMap.gbaKeysKey[6];*/"GBA_KEY_TURBO_A";
    public static final String GBA_KEY_TURBO_B = /* KeyMap.gbaKeysKey[7];*/"GBA_KEY_TURBO_B";
//    public static final String GBA_KEY_FASTFORWARD =  KeyMap.gbaKeysKey[8];/*"GBA_KEY_FASTFORWARD";*/


    public static final Map<String, String> gbaConvertMap = new HashMap<String, String>();

    static {
        gbaConvertMap.put(GBA_KEY_SELECT, KeyMap.gbaKeysKey[0]);
        gbaConvertMap.put(GBA_KEY_START, KeyMap.gbaKeysKey[1]);
        gbaConvertMap.put(GBA_KEY_A, KeyMap.gbaKeysKey[5]);
        gbaConvertMap.put(GBA_KEY_B, KeyMap.gbaKeysKey[3]);
        gbaConvertMap.put(GBA_KEY_L, KeyMap.gbaKeysKey[7]);
        gbaConvertMap.put(GBA_KEY_R, KeyMap.gbaKeysKey[6]);
        gbaConvertMap.put(GBA_KEY_TURBO_A, KeyMap.gbaKeysKey[2]);
        gbaConvertMap.put(GBA_KEY_TURBO_B, KeyMap.gbaKeysKey[4]);
    }

    static {
        gbaMap.put(KeyEvent.KEYCODE_BUTTON_SELECT, GBA_KEY_SELECT);
        gbaMap.put(KeyEvent.KEYCODE_BUTTON_START, GBA_KEY_START);

        gbaMap.put(KeyEvent.KEYCODE_BUTTON_R1, GBA_KEY_R);
        gbaMap.put(KeyEvent.KEYCODE_BUTTON_A, GBA_KEY_A);

        gbaMap.put(KeyEvent.KEYCODE_BUTTON_X, GBA_KEY_B);
        gbaMap.put(KeyEvent.KEYCODE_BUTTON_L1, GBA_KEY_L);

        gbaMap.put(KeyEvent.KEYCODE_BUTTON_B, GBA_KEY_TURBO_A);
        gbaMap.put(KeyEvent.KEYCODE_BUTTON_Y, GBA_KEY_TURBO_B);


      /*  gbaMap.put(KeyEvent.KEYCODE_BUTTON_SELECT, GBA_KEY_SELECT);
        gbaMap.put(KeyEvent.KEYCODE_BUTTON_START, GBA_KEY_START);

        gbaMap.put(KeyEvent.KEYCODE_BUTTON_A, GBA_KEY_R);
        gbaMap.put(KeyEvent.KEYCODE_BUTTON_B, GBA_KEY_A);

        gbaMap.put(KeyEvent.KEYCODE_BUTTON_X, GBA_KEY_B);
        gbaMap.put(KeyEvent.KEYCODE_BUTTON_Y, GBA_KEY_L);

        gbaMap.put(KeyEvent.KEYCODE_BUTTON_R1, GBA_KEY_TURBO_A);
        gbaMap.put(KeyEvent.KEYCODE_BUTTON_L1, GBA_KEY_TURBO_B);
*/
//        gbaMap.put(KeyEvent.KEYCODE_BUTTON_L2, GBA_KEY_FASTFORWARD);
    }


    public static final Map<Integer, String> fbaMap = new HashMap<Integer, String>();


    public static final String FBA_KEY_SELECT = /*KeyMap.fbaKeysKey[0];*/"FBA_KEY_SELECT";
    public static final String FBA_KEY_START  = /*KeyMap.fbaKeysKey[1];*/"FBA_KEY_START";
    public static final String FBA_KEY_A      = /*KeyMap.fbaKeysKey[2];*/"FBA_KEY_A";
    public static final String FBA_KEY_B      = /*KeyMap.fbaKeysKey[3];*/"FBA_KEY_B";

    public static final String FBA_KEY_C  = /*KeyMap.fbaKeysKey[4];*/"FBA_KEY_C";
    public static final String FBA_KEY_D  = /*KeyMap.fbaKeysKey[5];*/"FBA_KEY_D";
    public static final String FBA_KEY_E  = /*KeyMap.fbaKeysKey[6];*/"FBA_KEY_E";
    public static final String FBA_KEY_F  = /*KeyMap.fbaKeysKey[7];*/"FBA_KEY_F";
    public static final String FBA_KEY_AB = /*KeyMap.fbaKeysKey[8];*/"FBA_KEY_AB";

    public static final String FBA_KEY_CD  = /*KeyMap.fbaKeysKey[9];*/"FBA_KEY_CD";
    public static final String FBA_KEY_ABC = /*KeyMap.fbaKeysKey[10];*/"FBA_KEY_ABC";


    public static final Map<String, String> fbaConvertMap = new HashMap<String, String>();

    static {
        fbaConvertMap.put(FBA_KEY_SELECT, KeyMap.fbaKeysKey[0]);
        fbaConvertMap.put(FBA_KEY_START, KeyMap.fbaKeysKey[1]);
        fbaConvertMap.put(FBA_KEY_A, KeyMap.fbaKeysKey[2]);
        fbaConvertMap.put(FBA_KEY_B, KeyMap.fbaKeysKey[3]);
        fbaConvertMap.put(FBA_KEY_C, KeyMap.fbaKeysKey[4]);
        fbaConvertMap.put(FBA_KEY_D, KeyMap.fbaKeysKey[5]);
        fbaConvertMap.put(FBA_KEY_E, KeyMap.fbaKeysKey[6]);
        fbaConvertMap.put(FBA_KEY_F, KeyMap.fbaKeysKey[7]);
        fbaConvertMap.put(FBA_KEY_AB, KeyMap.fbaKeysKey[8]);
        fbaConvertMap.put(FBA_KEY_CD, KeyMap.fbaKeysKey[9]);
        fbaConvertMap.put(FBA_KEY_ABC, KeyMap.fbaKeysKey[10]);
    }


    static {
        fbaMap.put(KeyEvent.KEYCODE_BUTTON_SELECT, FBA_KEY_SELECT);
        fbaMap.put(KeyEvent.KEYCODE_BUTTON_START, FBA_KEY_START);

        fbaMap.put(KeyEvent.KEYCODE_BUTTON_A, FBA_KEY_B);
        fbaMap.put(KeyEvent.KEYCODE_BUTTON_B, FBA_KEY_D);

        fbaMap.put(KeyEvent.KEYCODE_BUTTON_X, FBA_KEY_A);
        fbaMap.put(KeyEvent.KEYCODE_BUTTON_Y, FBA_KEY_C);

        fbaMap.put(KeyEvent.KEYCODE_BUTTON_R1, FBA_KEY_AB);
        fbaMap.put(KeyEvent.KEYCODE_BUTTON_L1, FBA_KEY_E);
        fbaMap.put(KeyEvent.KEYCODE_BUTTON_R2, FBA_KEY_CD);
        fbaMap.put(KeyEvent.KEYCODE_BUTTON_L2, FBA_KEY_F);


        fbaMap.put(KeyEvent.KEYCODE_BUTTON_THUMBR, FBA_KEY_ABC);
    }

    public static final Map<Integer, String> sfcMap = new HashMap<Integer, String>();

    public static final String SFC_KEY_SELECT = "SFC_KEY_SELECT";
    public static final String SFC_KEY_START  =  /*KeyMap.sfcKeysKey[1];*/"SFC_KEY_START";
    public static final String SFC_KEY_X      =/* KeyMap.sfcKeysKey[2];*/"SFC_KEY_X";
    public static final String SFC_KEY_A      =/* KeyMap.sfcKeysKey[3];*/"SFC_KEY_A";

    public static final String SFC_KEY_Y =/* KeyMap.sfcKeysKey[4];*/"SFC_KEY_Y";
    public static final String SFC_KEY_B =/* KeyMap.sfcKeysKey[5];*/"SFC_KEY_B";
    public static final String SFC_KEY_L =/* KeyMap.sfcKeysKey[6];*/"SFC_KEY_L";
    public static final String SFC_KEY_R = /*KeyMap.sfcKeysKey[7];*/"SFC_KEY_R";

    public static final Map<String, String> sfcConvertMap = new HashMap<String, String>();

    static {
        sfcConvertMap.put(SFC_KEY_SELECT, KeyMap.sfcKeysKey[0]);
        sfcConvertMap.put(SFC_KEY_START, KeyMap.sfcKeysKey[1]);
        sfcConvertMap.put(SFC_KEY_X, KeyMap.sfcKeysKey[2]);
        sfcConvertMap.put(SFC_KEY_A, KeyMap.sfcKeysKey[3]);
        sfcConvertMap.put(SFC_KEY_Y, KeyMap.sfcKeysKey[4]);
        sfcConvertMap.put(SFC_KEY_B, KeyMap.sfcKeysKey[5]);
        sfcConvertMap.put(SFC_KEY_L, KeyMap.sfcKeysKey[6]);
        sfcConvertMap.put(SFC_KEY_R, KeyMap.sfcKeysKey[7]);
    }


    static {
        sfcMap.put(KeyEvent.KEYCODE_BUTTON_SELECT, SFC_KEY_SELECT);
        sfcMap.put(KeyEvent.KEYCODE_BUTTON_START, SFC_KEY_START);

        sfcMap.put(KeyEvent.KEYCODE_BUTTON_A, SFC_KEY_A);
        sfcMap.put(KeyEvent.KEYCODE_BUTTON_B, SFC_KEY_B);

        sfcMap.put(KeyEvent.KEYCODE_BUTTON_X, SFC_KEY_X);
        sfcMap.put(KeyEvent.KEYCODE_BUTTON_Y, SFC_KEY_Y);

        sfcMap.put(KeyEvent.KEYCODE_BUTTON_R1, SFC_KEY_R);
        sfcMap.put(KeyEvent.KEYCODE_BUTTON_L1, SFC_KEY_L);

//        sfcMap.put(KeyEvent.KEYCODE_BUTTON_L2, SFC_KEY_FASTFORWARD);


    }


    public static final Map<Integer, String> pspMap = new HashMap<Integer, String>();

    public static final String PSP_KEY_SELECT = /*KeyMap.pspKeysKey[0];*/"PSP_KEY_SELECT";
    public static final String PSP_KEY_START  = /*KeyMap.pspKeysKey[1];*/"PSP_KEY_START";
    public static final String PSP_KEY_X      = /*KeyMap.pspKeysKey[2];*/"PSP_KEY_X";
    public static final String PSP_KEY_A      = /*KeyMap.pspKeysKey[3];*/"PSP_KEY_A";

    public static final String PSP_KEY_Y = /*KeyMap.pspKeysKey[4];*/"PSP_KEY_Y";
    public static final String PSP_KEY_B = /*KeyMap.pspKeysKey[5];*/"PSP_KEY_B";
    public static final String PSP_KEY_L =  /*KeyMap.pspKeysKey[6];*/"PSP_KEY_L";
    public static final String PSP_KEY_R = /*KeyMap.pspKeysKey[7];*/"PSP_KEY_R";

    public static final Map<String, String> pspConvertMap = new HashMap<String, String>();

    static {
        pspConvertMap.put(PSP_KEY_SELECT, KeyMap.pspKeysKey[0]);
        pspConvertMap.put(PSP_KEY_START, KeyMap.pspKeysKey[1]);
        pspConvertMap.put(PSP_KEY_X, KeyMap.pspKeysKey[2]);
        pspConvertMap.put(PSP_KEY_A, KeyMap.pspKeysKey[3]);
        pspConvertMap.put(PSP_KEY_Y, KeyMap.pspKeysKey[4]);
        pspConvertMap.put(PSP_KEY_B, KeyMap.pspKeysKey[5]);
        pspConvertMap.put(PSP_KEY_L, KeyMap.pspKeysKey[6]);
        pspConvertMap.put(PSP_KEY_R, KeyMap.pspKeysKey[7]);

    }


    static {
        pspMap.put(KeyEvent.KEYCODE_BUTTON_SELECT, PSP_KEY_SELECT);
        pspMap.put(KeyEvent.KEYCODE_BUTTON_START, PSP_KEY_START);

        pspMap.put(KeyEvent.KEYCODE_BUTTON_X, PSP_KEY_X);
        pspMap.put(KeyEvent.KEYCODE_BUTTON_A, PSP_KEY_A);

        pspMap.put(KeyEvent.KEYCODE_BUTTON_Y, PSP_KEY_Y);
        pspMap.put(KeyEvent.KEYCODE_BUTTON_B, PSP_KEY_B);

        pspMap.put(KeyEvent.KEYCODE_BUTTON_L1, PSP_KEY_L);
        pspMap.put(KeyEvent.KEYCODE_BUTTON_R1, PSP_KEY_R);


    }



    public static final Map<Integer, String> mdMap = new HashMap<Integer, String>();

    public static final String MD_KEY_SELECT = "MD_KEY_SELECT";
    public static final String MD_KEY_START  = "MD_KEY_START";
    public static final String MD_KEY_X      = "MD_KEY_X";
    public static final String MD_KEY_A      = "MD_KEY_A";

    public static final String MD_KEY_Y = "MD_KEY_Y";
    public static final String MD_KEY_B = "MD_KEY_B";
    public static final String MD_KEY_Z= "MD_KEY_Z";
    public static final String MD_KEY_C = "MD_KEY_C";

    public static final Map<String, String> mdConvertMap = new HashMap<String, String>();

    static {
        mdConvertMap.put(MD_KEY_SELECT, KeyMap.mdKeysKey[0]);
        mdConvertMap.put(MD_KEY_START, KeyMap.mdKeysKey[1]);
        mdConvertMap.put(MD_KEY_Y, KeyMap.mdKeysKey[4]);
        mdConvertMap.put(MD_KEY_B, KeyMap.mdKeysKey[3]);
        mdConvertMap.put(MD_KEY_X, KeyMap.mdKeysKey[2]);
        mdConvertMap.put(MD_KEY_A, KeyMap.mdKeysKey[5]);

        mdConvertMap.put(MD_KEY_C, KeyMap.mdKeysKey[6]);
        mdConvertMap.put(MD_KEY_Z, KeyMap.mdKeysKey[7]);


    }


    static {
        mdMap.put(KeyEvent.KEYCODE_BUTTON_SELECT, MD_KEY_SELECT);
        mdMap.put(KeyEvent.KEYCODE_BUTTON_START, MD_KEY_START);

        mdMap.put(KeyEvent.KEYCODE_BUTTON_X, MD_KEY_X);
        mdMap.put(KeyEvent.KEYCODE_BUTTON_B, MD_KEY_B);

        mdMap.put(KeyEvent.KEYCODE_BUTTON_Y, MD_KEY_Y);
        mdMap.put(KeyEvent.KEYCODE_BUTTON_A, MD_KEY_A);

        mdMap.put(KeyEvent.KEYCODE_BUTTON_R1, MD_KEY_C);
        mdMap.put(KeyEvent.KEYCODE_BUTTON_L1, MD_KEY_Z);



    }


    public static final Map<Integer, String> psMap = new HashMap<Integer, String>();

    public static final String PS_KEY_SELECT = "PS_KEY_SELECT";
    public static final String PS_KEY_START  = "PS_KEY_START";
    public static final String PS_KEY_X      = "PS_KEY_X";
    public static final String PS_KEY_A      = "PS_KEY_A";

    public static final String PS_KEY_Y = "PS_KEY_Y";
    public static final String PS_KEY_B = "PS_KEY_B";
    public static final String PS_KEY_L1= "PS_KEY_L1";
    public static final String PS_KEY_R1 = "PS_KEY_R1";
    public static final String PS_KEY_L2= "PS_KEY_L2";
    public static final String PS_KEY_R2 = "PS_KEY_R2";

    public static final Map<String, String> psConvertMap = new HashMap<String, String>();

    static {
        psConvertMap.put(PS_KEY_SELECT, KeyMap.psKeysKey[0]);
        psConvertMap.put(PS_KEY_START, KeyMap.psKeysKey[1]);
        psConvertMap.put(PS_KEY_X, KeyMap.psKeysKey[2]);
        psConvertMap.put(PS_KEY_A, KeyMap.psKeysKey[3]);
        psConvertMap.put(PS_KEY_Y, KeyMap.psKeysKey[4]);
        psConvertMap.put(PS_KEY_B, KeyMap.psKeysKey[5]);

        psConvertMap.put(PS_KEY_L1, KeyMap.psKeysKey[6]);
        psConvertMap.put(PS_KEY_R1, KeyMap.psKeysKey[7]);

        psConvertMap.put(PS_KEY_L2, KeyMap.psKeysKey[8]);
        psConvertMap.put(PS_KEY_R2, KeyMap.psKeysKey[9]);


    }


    static {
        psMap.put(KeyEvent.KEYCODE_BUTTON_SELECT, PS_KEY_SELECT);
        psMap.put(KeyEvent.KEYCODE_BUTTON_START, PS_KEY_START);

        psMap.put(KeyEvent.KEYCODE_BUTTON_X, PS_KEY_X);
        psMap.put(KeyEvent.KEYCODE_BUTTON_B, PS_KEY_B);

        psMap.put(KeyEvent.KEYCODE_BUTTON_Y, PS_KEY_Y);
        psMap.put(KeyEvent.KEYCODE_BUTTON_A, PS_KEY_A);

        psMap.put(KeyEvent.KEYCODE_BUTTON_R1, PS_KEY_R1);
        psMap.put(KeyEvent.KEYCODE_BUTTON_L1, PS_KEY_L1);

        psMap.put(KeyEvent.KEYCODE_BUTTON_R2, PS_KEY_R2);
        psMap.put(KeyEvent.KEYCODE_BUTTON_L2, PS_KEY_L2);

    }



    public static final Map<Integer, String> wscMap = new HashMap<Integer, String>();


    public static final String WSC_KEY_SELECT = "WSC_KEY_SELECT";
    public static final String WSC_KEY_START  = "WSC_KEY_START";
    public static final String WSC_KEY_A      = "WSC_KEY_A";
    public static final String WSC_KEY_B = "WSC_KEY_B";
    public static final String WSC_KEY_L1= "WSC_KEY_L1";
    public static final String WSC_KEY_R1 = "WSC_KEY_R1";
    public static final String WSC_KEY_L2= "WSC_KEY_L2";
    public static final String WSC_KEY_R2 = "WSC_KEY_R2";

    public static final String WSC_KEY_LEFT= "WSC_KEY_LEFT";
    public static final String WSC_KEY_UP = "WSC_KEY_UP";
    public static final String WSC_KEY_RIGHT= "WSC_KEY_RIGHT";
    public static final String WSC_KEY_DOWN = "WSC_KEY_DOWN";


    public static final Map<String, String> wscConvertMap = new HashMap<String, String>();


    static {
        wscConvertMap.put(WSC_KEY_SELECT, KeyMap.wscKeysKey[0]);
        wscConvertMap.put(WSC_KEY_START, KeyMap.wscKeysKey[1]);
        wscConvertMap.put(WSC_KEY_A, KeyMap.wscKeysKey[2]);
        wscConvertMap.put(WSC_KEY_B, KeyMap.wscKeysKey[3]);
        wscConvertMap.put(WSC_KEY_L1, KeyMap.wscKeysKey[4]);
        wscConvertMap.put(WSC_KEY_R1, KeyMap.wscKeysKey[5]);

        wscConvertMap.put(WSC_KEY_L2, KeyMap.wscKeysKey[6]);
        wscConvertMap.put(WSC_KEY_R2, KeyMap.wscKeysKey[7]);

        wscConvertMap.put(WSC_KEY_LEFT, KeyMap.wscKeysKey[8]);
        wscConvertMap.put(WSC_KEY_UP, KeyMap.wscKeysKey[9]);

        wscConvertMap.put(WSC_KEY_RIGHT, KeyMap.wscKeysKey[10]);
        wscConvertMap.put(WSC_KEY_DOWN, KeyMap.wscKeysKey[11]);
    }


    static {
        wscMap.put(KeyEvent.KEYCODE_BUTTON_SELECT, WSC_KEY_SELECT);
        wscMap.put(KeyEvent.KEYCODE_BUTTON_START, WSC_KEY_START);

        wscMap.put(KeyEvent.KEYCODE_BUTTON_A, WSC_KEY_A);
        wscMap.put(KeyEvent.KEYCODE_BUTTON_B, WSC_KEY_B);

        wscMap.put(KeyEvent.KEYCODE_BUTTON_L1, WSC_KEY_L1);
        wscMap.put(KeyEvent.KEYCODE_BUTTON_R1, WSC_KEY_R1);

        wscMap.put(KeyEvent.KEYCODE_BUTTON_L2, WSC_KEY_L2);
        wscMap.put(KeyEvent.KEYCODE_BUTTON_R2, WSC_KEY_R2);

        wscMap.put(KeyEvent.KEYCODE_DPAD_LEFT, WSC_KEY_LEFT);
        wscMap.put(KeyEvent.KEYCODE_DPAD_UP, WSC_KEY_UP);
        wscMap.put(KeyEvent.KEYCODE_DPAD_RIGHT, WSC_KEY_RIGHT);
        wscMap.put(KeyEvent.KEYCODE_DPAD_DOWN, WSC_KEY_DOWN);

    }















    public static final Map<Integer, String> gbcMap = new HashMap<Integer, String>();


    public static final String GBC_KEY_SELECT = /*KeyMap.fcKeysKey[0];*/"GBC_KEY_SELECT";
    public static final String GBC_KEY_START  =/* KeyMap.fcKeysKey[1];*/"GBC_KEY_START";
    public static final String GBC_KEY_A      =/* KeyMap.fcKeysKey[2];*/"GBC_KEY_A";
    public static final String GBC_KEY_B      = /*KeyMap.fcKeysKey[3];*/"GBC_KEY_B";

    public static final String GBC_KEY_TURBO_A = /*KeyMap.fcKeysKey[4];*/"GBC_KEY_TURBO_A";
    public static final String GBC_KEY_TURBO_B = /*KeyMap.fcKeysKey[5];*/"GBC_KEY_TURBO_B";
    public static final String GBC_KEY_AB      = /*KeyMap.fcKeysKey[6];*/"GBC_KEY_AB";

    public static final Map<String, String> gbcConvertMap = new HashMap<String, String>();

    static {
        gbcConvertMap.put(GBC_KEY_SELECT, KeyMap.gbcKeysKey[0]);
        gbcConvertMap.put(GBC_KEY_START, KeyMap.gbcKeysKey[1]);
        gbcConvertMap.put(GBC_KEY_TURBO_B, KeyMap.gbcKeysKey[2]);
        gbcConvertMap.put(GBC_KEY_TURBO_A, KeyMap.gbcKeysKey[3]);
        gbcConvertMap.put(GBC_KEY_B, KeyMap.gbcKeysKey[4]);
        gbcConvertMap.put(GBC_KEY_A, KeyMap.gbcKeysKey[5]);
        gbcConvertMap.put(GBC_KEY_AB, KeyMap.gbcKeysKey[6]);
    }

    {
        gbcMap.put(KeyEvent.KEYCODE_BUTTON_SELECT,GBC_KEY_SELECT);
        gbcMap.put(KeyEvent.KEYCODE_BUTTON_START, GBC_KEY_START);

        gbcMap.put(KeyEvent.KEYCODE_BUTTON_A, GBC_KEY_A);
        gbcMap.put(KeyEvent.KEYCODE_BUTTON_B, GBC_KEY_B);

        gbcMap.put(KeyEvent.KEYCODE_BUTTON_X, GBC_KEY_TURBO_A);
        gbcMap.put(KeyEvent.KEYCODE_BUTTON_Y,GBC_KEY_TURBO_B);

        gbcMap.put(KeyEvent.KEYCODE_BUTTON_R1, GBC_KEY_AB);

    }




    public static final Map<Integer, String> dcMap = new HashMap<Integer, String>();

    public static final String DC_KEY_START  =/* KeyMap.fcKeysKey[1];*/"DC_KEY_START";

    public static final String DC_KEY_A      =/* KeyMap.fcKeysKey[2];*/"DC_KEY_A";
    public static final String DC_KEY_B      = /*KeyMap.fcKeysKey[3];*/"DC_KEY_B";

    public static final String DC_KEY_X = /*KeyMap.fcKeysKey[4];*/"DC_KEY_X";
    public static final String DC_KEY_Y = /*KeyMap.fcKeysKey[5];*/"DC_KEY_Y";
    public static final String DC_KEY_L1 = /*KeyMap.fcKeysKey[5];*/"DC_KEY_L1";
    public static final String DC_KEY_R1 = /*KeyMap.fcKeysKey[5];*/"DC_KEY_R1";

    public static final Map<String, String> dcConvertMap = new HashMap<String, String>();

    static {
        dcConvertMap.put(DC_KEY_START, KeyMap.dcKeysKey[0]);
        dcConvertMap.put(DC_KEY_A, KeyMap.dcKeysKey[1]);
        dcConvertMap.put(DC_KEY_B, KeyMap.dcKeysKey[2]);
        dcConvertMap.put(DC_KEY_X, KeyMap.dcKeysKey[3]);
        dcConvertMap.put(DC_KEY_Y, KeyMap.dcKeysKey[4]);
        dcConvertMap.put(DC_KEY_L1, KeyMap.dcKeysKey[5]);
        dcConvertMap.put(DC_KEY_R1, KeyMap.dcKeysKey[6]);
    }

    {
        dcMap.put(KeyEvent.KEYCODE_BUTTON_START, DC_KEY_START);

        dcMap.put(KeyEvent.KEYCODE_BUTTON_A, DC_KEY_A);
        dcMap.put(KeyEvent.KEYCODE_BUTTON_B, DC_KEY_B);

        dcMap.put(KeyEvent.KEYCODE_BUTTON_X, DC_KEY_X);
        dcMap.put(KeyEvent.KEYCODE_BUTTON_Y,DC_KEY_Y);

        dcMap.put(KeyEvent.KEYCODE_BUTTON_R1, DC_KEY_R1);
        dcMap.put(KeyEvent.KEYCODE_BUTTON_L1, DC_KEY_L1);
    }





    public static final Map<Integer, String> n64Map = new HashMap<Integer, String>();

    public static final String N64_KEY_START  = "N64_KEY_START";
    public static final String N64_KEY_X      = "N64_KEY_X";
    public static final String N64_KEY_A      = "N64_KEY_A";

    public static final String N64_KEY_Y = "N64_KEY_Y";
    public static final String N64_KEY_B = "N64_KEY_B";
    public static final String N64_KEY_L1= "N64_KEY_L1";
    public static final String N64_KEY_R1 = "N64_KEY_R1";
    public static final String N64_KEY_L2= "N64_KEY_L2";
    public static final String N64_KEY_R2 = "N64_KEY_R2";

    public static final String N64_KEY_ABC = "N64_KEY_ABC";



    public static final Map<String, String> n64ConvertMap = new HashMap<String, String>();

    static {
        n64ConvertMap.put(N64_KEY_START, KeyMap.n64KeysKey[0]);
        n64ConvertMap.put(N64_KEY_A, KeyMap.n64KeysKey[1]);
        n64ConvertMap.put(N64_KEY_B, KeyMap.n64KeysKey[2]);
        n64ConvertMap.put(N64_KEY_X, KeyMap.n64KeysKey[3]);
        n64ConvertMap.put(N64_KEY_Y, KeyMap.n64KeysKey[4]);

        n64ConvertMap.put(N64_KEY_L1, KeyMap.n64KeysKey[5]);
        n64ConvertMap.put(N64_KEY_R1, KeyMap.n64KeysKey[6]);

        n64ConvertMap.put(N64_KEY_L2, KeyMap.n64KeysKey[7]);
        n64ConvertMap.put(N64_KEY_R2, KeyMap.n64KeysKey[8]);

        n64ConvertMap.put(N64_KEY_ABC, KeyMap.n64KeysKey[9]);
    }


    static {
        n64Map.put(KeyEvent.KEYCODE_BUTTON_START, N64_KEY_START);

        n64Map.put(KeyEvent.KEYCODE_BUTTON_X, N64_KEY_X);
        n64Map.put(KeyEvent.KEYCODE_BUTTON_B, N64_KEY_B);

        n64Map.put(KeyEvent.KEYCODE_BUTTON_Y, N64_KEY_Y);
        n64Map.put(KeyEvent.KEYCODE_BUTTON_A, N64_KEY_A);

        n64Map.put(KeyEvent.KEYCODE_BUTTON_R1, N64_KEY_R1);
        n64Map.put(KeyEvent.KEYCODE_BUTTON_L1, N64_KEY_L1);

        n64Map.put(KeyEvent.KEYCODE_BUTTON_R2, N64_KEY_R2);
        n64Map.put(KeyEvent.KEYCODE_BUTTON_L2, N64_KEY_L2);
        n64Map.put(KeyEvent.KEYCODE_BUTTON_THUMBL, N64_KEY_ABC);
    }




















}
